function init() {
   refreshOrders();
}

function refreshOrders() {
   var ajax = new Ajax.Request(
      "../bin/getOrders.php",
      {
         method: "post",
         postBody: $("ordersForm").serialize(),
         onSuccess: refreshOrdersOver
      }
   );
}

function refreshOrdersOver(req) {
   var div = $("ordersDiv");
   div.innerHTML = req.responseText;
}

function goonClicked(itemID) {
   var ajax = new Ajax.Request(
      "../bin/updateOrder.php",
      {
         postBody: "op=goon&from=admin&orderID=" + itemID,
         onSuccess: updateOrderOver
      }
   );
}

function cancelClicked(itemID) {
   var ajax = new Ajax.Request(
      "../bin/updateOrder.php",
      {
         postBody: "op=cancel&from=admin&orderID=" + itemID,
         onSuccess: updateOrderOver
      }
   );
}

function updateOrderOver(req) {
   if(req.responseText == "Success") {
      refreshOrders();
   }
   else {
      alert("Error on update");
   }
}